{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  宁越\n",
    "+ 学号  0164964"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第一个家庭:\n",
      "此户人家为贫困户\n",
      "给予义务教育安全保障,帮扶选择1，不帮扶为0\n",
      "0\n",
      "给予住房安全保障,帮扶选择1，不帮扶为0\n",
      "0\n",
      "给予饮水安全保障,帮扶选择1，不帮扶为0\n",
      "0\n",
      "扶贫不成功\n",
      "\n",
      "第二个家庭:\n",
      "此户人家不属于贫困户\n",
      "\n",
      "第三个家庭:\n",
      "此户人家为贫困户\n",
      "给予义务教育安全保障,帮扶选择1，不帮扶为0\n",
      "1\n",
      "给予饮水安全保障,帮扶选择1，不帮扶为0\n",
      "0\n",
      "给予肉蛋奶豆安全保障,帮扶选择1，不帮扶为0\n",
      "0\n",
      "扶贫成功\n"
     ]
    }
   ],
   "source": [
    "class poor(object):\n",
    "    def __init__(self,education,house,water,mems):\n",
    "        self.education=education\n",
    "        self.house=house\n",
    "        self.water=water\n",
    "        self.mems=mems\n",
    "    def really_poor(self):\n",
    "        self.sum = 0\n",
    "        if self.education == 0:\n",
    "            self.sum += 1\n",
    "        if self.house == 0:\n",
    "            self.sum += 1\n",
    "        if self.water == 0:\n",
    "            self.sum += 1\n",
    "        if self.mems == 0:\n",
    "            self.sum += 1\n",
    "        if self.sum > 2:\n",
    "            print('此户人家为贫困户')\n",
    "        else:\n",
    "            print(\"此户人家不属于贫困户\")\n",
    "    def help_poor(self):\n",
    "        if self.sum>2:\n",
    "            if self.education==0:\n",
    "                print('给予义务教育安全保障,帮扶选择1，不帮扶为0')\n",
    "                self.education=int(input())\n",
    "                if self.education==1:\n",
    "                    self.sum-=1\n",
    "            if self.house==0:\n",
    "                print('给予住房安全保障,帮扶选择1，不帮扶为0')\n",
    "                self.house=int(input())\n",
    "                if self.house==1:\n",
    "                    self.sum-=1\n",
    "            if self.water==0:\n",
    "                print('给予饮水安全保障,帮扶选择1，不帮扶为0')\n",
    "                self.water=int(input())\n",
    "                if self.water==1:\n",
    "                    self.sum-=1\n",
    "            if self.mems==0:\n",
    "                print('给予肉蛋奶豆安全保障,帮扶选择1，不帮扶为0')\n",
    "                self.mems=int(input())\n",
    "                if self.mems==1:\n",
    "                    self.sum-=1\n",
    "            if self.sum>2:\n",
    "                print(\"扶贫不成功\")\n",
    "            else:\n",
    "                print(\"扶贫成功\")\n",
    "\n",
    "family1=poor(0,0,0,1)\n",
    "print('第一个家庭:')\n",
    "family1.really_poor()\n",
    "family1.help_poor()\n",
    "family2=poor(1,1,0,1)\n",
    "print('\\n第二个家庭:')\n",
    "family2.really_poor()\n",
    "family2.help_poor()\n",
    "family3=poor(0,1,0,0)\n",
    "print('\\n第三个家庭:')\n",
    "family3.really_poor()\n",
    "family3.help_poor()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "营业部第一名好嘛:\n",
      "请输入分数标准,实行百分制\n",
      "90\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "6\n",
      "体重正常\n",
      "\n",
      "emmm,业绩就不说了,还熬夜看球？？？\n",
      "请输入分数标准,实行百分制\n",
      "50\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "6\n",
      "BMI可能偏大\n",
      "\n",
      "洁癖主任🌚🌚🌚:\n",
      "请输入分数标准,实行百分制\n",
      "80\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "8\n",
      "体重正常\n",
      "\n",
      "八卦传送机🌚🌚🌚:\n",
      "请输入分数标准,实行百分制\n",
      "65\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "7\n",
      "BMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class student(object):\n",
    "    def __init__(self,name,score,sleep_time):\n",
    "        self.name=name\n",
    "        self.score=score\n",
    "        self.sleep_time=sleep_time\n",
    "    def predict(self,score,sleep_time):\n",
    "        print('请输入分数标准,实行百分制')\n",
    "        standard_score=int(input())\n",
    "        print('请输入睡眠时间标准,其单位为小时')\n",
    "        standard_sleep_time=int(input())\n",
    "        if (self.score > standard_score) & (self.sleep_time<standard_sleep_time):\n",
    "            print ('BMI可能偏大')\n",
    "        else:\n",
    "            print('体重正常')\n",
    "\n",
    "man1=student('小林子-最帅的Maki吉娃娃🐶',100,8)\n",
    "print(\"营业部第一名好嘛:\")\n",
    "man1.predict(score=100,sleep_time=8)\n",
    "\n",
    "man2=student('甜圭-人生赢家春田田',60,3)\n",
    "print(\"\\nemmm,业绩就不说了,还熬夜看球？？？\")\n",
    "man2.predict(score=60,sleep_time=3)\n",
    "\n",
    "man3=student('政宗主任-只能是爱情苦情剧中Maki的前男友了',85,9)\n",
    "print(\"\\n洁癖主任🌚🌚🌚:\")\n",
    "man3.predict(score=85,sleep_time=9)\n",
    "\n",
    "man4=student('舞香さん其实是个牧春女孩',70,6)\n",
    "print(\"\\n八卦传送机🌚🌚🌚:\")\n",
    "man4.predict(score=70,sleep_time=6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "营业部第一名好嘛:\n",
      "请输入分数标准,实行百分制\n",
      "90\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "6\n",
      "体重正常\n",
      "小林子除了是家务苦手，真的超棒啊🌝🌝🌝\n",
      "\n",
      "emmm,业绩就不说了,还熬夜看球？？？\n",
      "请输入分数标准,实行百分制\n",
      "50\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "6\n",
      "BMI可能偏大\n",
      "这样还不运动的咩，简直是废柴一个啊🌚🌚🌚\n",
      "不是我说，春田さん有了Maki，就可以为所欲为了吗？？？\n",
      "emmm,悄咪咪的说:好像真的可以哎👀\n",
      "\n",
      "洁癖主任🌚🌚🌚:\n",
      "请输入分数标准,实行百分制\n",
      "80\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "8\n",
      "体重正常\n",
      "主任其实也很棒，不如和黑泽部长在一起吧🙈🙈🙈\n",
      "\n",
      "八卦传送机🌚🌚🌚:\n",
      "请输入分数标准,实行百分制\n",
      "65\n",
      "请输入睡眠时间标准,其单位为小时\n",
      "7\n",
      "BMI可能偏大\n",
      "这样还不运动的咩，简直是废柴一个啊🌚🌚🌚\n",
      "请铁平监督一下好吗，不要再给她做什么奇怪的东西吃了吧\n"
     ]
    }
   ],
   "source": [
    "class running(student):\n",
    "    def __init__(self,name,score,sleep_time,running_time):\n",
    "        super().__init__(name,score,sleep_time)\n",
    "        self.running_time=running_time\n",
    "    def whether_fat(self,score,sleep_time,running_time):\n",
    "        print('请输入分数标准,实行百分制')\n",
    "        standard_score=int(input())\n",
    "        print('请输入睡眠时间标准,其单位为小时')\n",
    "        standard_sleep_time=int(input())\n",
    "        if (self.score > standard_score) & (self.sleep_time<standard_sleep_time):\n",
    "            print ('BMI可能偏大')\n",
    "            if self.running_time>30:\n",
    "                    print('趋于正常')\n",
    "            else:\n",
    "                     print('这样还不运动的咩，简直是废柴一个啊🌚🌚🌚')\n",
    "        else:\n",
    "            print('体重正常')\n",
    "\n",
    "man1=running('小林子-最帅的Maki&吉娃娃🐶',100,8,60)\n",
    "print(\"营业部第一名好嘛:\")\n",
    "man1.whether_fat(score=100,sleep_time=8,running_time=60)\n",
    "print('小林子除了是家务苦手，真的超棒啊🌝🌝🌝')\n",
    "\n",
    "man2=running('甜圭-人生赢家春田田',60,3,0)\n",
    "print(\"\\nemmm,业绩就不说了,还熬夜看球？？？\")\n",
    "man2.whether_fat(score=60,sleep_time=3,running_time=0)\n",
    "print('不是我说，春田さん有了Maki，就可以为所欲为了吗？？？\\nemmm,悄咪咪的说:好像真的可以哎👀')\n",
    "\n",
    "man3=running('政宗主任-只能是爱情苦情剧中Maki的前男友了',85,9,120)\n",
    "print(\"\\n洁癖主任🌚🌚🌚:\")\n",
    "man3.whether_fat(score=85,sleep_time=9,running_time=120)\n",
    "print(\"主任其实也很棒，不如和黑泽部长在一起吧🙈🙈🙈\")\n",
    "\n",
    "man4=running('舞香さん其实是个牧春女孩',70,6,10)\n",
    "print(\"\\n八卦传送机🌚🌚🌚:\")\n",
    "man4.whether_fat(score=70,sleep_time=6,running_time=10)\n",
    "print('请铁平监督一下好吗，不要再给她做什么奇怪的东西吃了吧')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
